//
//  EnvironmentManager.swift
//  Swift-Codedase
//
//  Created by xyanl on 2023/7/25.
//
//  环境管理
import Foundation
import JKSwiftExtension

/// 开发环境类型
enum SystemEnvType {
    case release // 正式、生产
    case development // 开发
}


class SystemEnvManager {
    
    /// 配置数据库版本
    var realmVersion: String = ""
    
    /// 默认开发环境
    var envType: SystemEnvType = .development {
        didSet {
            resetEnv()
        }
    }
    
    /// 网络请求域名
//    var HttpUrl = ""
    /// 腾讯 bugly
//    var BuglyID = ""
    
    
    var phpUrl = ""
    var javaUrl = ""
    /// 货代
    var forwarderUrl = ""
    /// 线上展会
    var exhibitionUrl = ""
    /// 商城
    var shopUrl = ""
    /// 代销商品
    var consignmentUrl = ""
    
    /// 货代接口域名
    var freightForwardingUrl = ""
    
    /// true: 正式 false: 开发
    var isRelease: Bool {
        envType == .release
    }
    
    /// 单例
    static let shared: SystemEnvManager = SystemEnvManager()
    /// 构造
    private init() {
        // 初始化
        resetEnv()
    }
    
    func resetEnv() {
        if envType == .release {
            // 正式 国内
            phpUrl = "https://app.gluz.com.cn"
            javaUrl = "https://exhibition.gluz.com.cn"
            freightForwardingUrl = "https://freight.gluz.com.cn"

            forwarderUrl = "https://test.gluz.com.cn/#"
            exhibitionUrl = "https://online.gluz.com.cn/#"
            shopUrl = "https://shop.gluz.com.cn/ts/#"
            consignmentUrl = "https://shop.gluz.com.cn/constructor"
            
        } else if envType == .development {
            // 开发 国内
            phpUrl = "https://app1.gluz.com.cn"
            javaUrl = "http://101.201.101.194:8088"
            freightForwardingUrl = "https://freight1.gluz.com.cn"
            
            forwarderUrl = "https://test1.gluz.com.cn/#"
            exhibitionUrl = "https://online1.gluz.com.cn/#"
            shopUrl = "https://shop1.gluz.com.cn/ts/#"
            consignmentUrl = "https://shop1.gluz.com.cn/constructor"
        }
    }
}
